#ifndef MARCHINGTETRAHEDRONS_H
#define MARCHINGTETRAHEDRONS_H
#include <iostream>
#include <CGAL/Simple_cartesian.h>
#include "geometricprimitives.h"

typedef CGAL::Simple_cartesian<double>  K;

using namespace std;

class MarchingTetrahedrons{
    /*
   Polygonise a tetrahedron given its vertices within a cube
   This is an alternative algorithm to polygonisegrid.
   It results in a smoother surface but more triangular facets.

                      + 0
                     /|\
                    / | \
                   /  |  \
                  /   |   \
                 /    |    \
                /     |     \
               +-------------+ 1
              3 \     |     /
                 \    |    /
                  \   |   /
                   \  |  /
                    \ | /
                     \|/
                      + 2

   It's main purpose is still to polygonise a gridded dataset and
   would normally be called 6 times, one for each tetrahedron making
   up the grid cell.
   Given the grid labelling as in PolygniseGrid one would call
      PolygoniseTri(grid,iso,triangles,0,2,3,7);
      PolygoniseTri(grid,iso,triangles,0,2,6,7);
      PolygoniseTri(grid,iso,triangles,0,4,6,7);
      PolygoniseTri(grid,iso,triangles,0,6,1,2);
      PolygoniseTri(grid,iso,triangles,0,6,1,4);
      PolygoniseTri(grid,iso,triangles,5,6,1,4);
*/

    public:

    static int PolygoniseTri(GRIDCELL g,double iso, TRIANGLE *tri,int v0,int v1,int v2,int v3);
    static XYZ VertexInterp(double isolevel , XYZ p1 , XYZ p2 , double valp1 , double valp2);
    static void calcNormal(TRIANGLE &tri);
};

#endif // MARCHINGTETRAHEDRONS_H
